package com.ruoyi.web.controller.safety;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.safety.domain.PointValueDict;
import com.ruoyi.safety.service.IPointValueDictService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 测点数值类型字典Controller
 * 
 * @author ruoyi
 * @date 2024-11-06
 */
@RestController
@RequestMapping("/safety/pointValueDict")
public class PointValueDictController extends BaseController
{
    @Autowired
    private IPointValueDictService pointValueDictService;

    /**
     * 查询测点数值类型字典列表
     */
    @PreAuthorize("@ss.hasPermi('safety:dict:list')")
    @GetMapping("/list")
    public TableDataInfo list(PointValueDict pointValueDict)
    {
        startPage();
        List<PointValueDict> list = pointValueDictService.selectPointValueDictList(pointValueDict);
        return getDataTable(list);
    }

    /**
     * 导出测点数值类型字典列表
     */
    @PreAuthorize("@ss.hasPermi('safety:dict:export')")
    @Log(title = "测点数值类型字典", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PointValueDict pointValueDict)
    {
        List<PointValueDict> list = pointValueDictService.selectPointValueDictList(pointValueDict);
        ExcelUtil<PointValueDict> util = new ExcelUtil<PointValueDict>(PointValueDict.class);
        util.exportExcel(response, list, "测点数值类型字典数据");
    }

    /**
     * 获取测点数值类型字典详细信息
     */
    @PreAuthorize("@ss.hasPermi('safety:dict:query')")
    @GetMapping(value = "/{pointValueId}")
    public AjaxResult getInfo(@PathVariable("pointValueId") String pointValueId)
    {
        return success(pointValueDictService.selectPointValueDictByPointValueId(pointValueId));
    }

    /**
     * 新增测点数值类型字典
     */
    @PreAuthorize("@ss.hasPermi('safety:dict:add')")
    @Log(title = "测点数值类型字典", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PointValueDict pointValueDict)
    {
        return toAjax(pointValueDictService.insertPointValueDict(pointValueDict));
    }

    /**
     * 修改测点数值类型字典
     */
    @PreAuthorize("@ss.hasPermi('safety:dict:edit')")
    @Log(title = "测点数值类型字典", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PointValueDict pointValueDict)
    {
        return toAjax(pointValueDictService.updatePointValueDict(pointValueDict));
    }

    /**
     * 删除测点数值类型字典
     */
    @PreAuthorize("@ss.hasPermi('safety:dict:remove')")
    @Log(title = "测点数值类型字典", businessType = BusinessType.DELETE)
	@DeleteMapping("/{pointValueIds}")
    public AjaxResult remove(@PathVariable String[] pointValueIds)
    {
        return toAjax(pointValueDictService.deletePointValueDictByPointValueIds(pointValueIds));
    }
}
